package com.example.flower_shop.controller.usr;

import com.example.flower_shop.service.usr.AuthService;
import com.example.flower_shop.vo.auth.AuthInfoRespVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 用户权限菜单
 */
@Tag(name = "用户权限菜单")
@RestController
@RequestMapping("/api/auth")
public class AuthController {

    @Resource
    private AuthService authService;

    /**
     * 获取用户权限
     *
     * @return
     */
    @GetMapping("/perm")
    @Operation(summary = "获取用户权限")
    public AuthInfoRespVO getPerm() {
        List<String> perms = authService.getPerm();
        return AuthInfoRespVO.builder().perms(perms).build();
    }

    /**
     * 获取用户角色
     *
     * @return
     */
    @GetMapping("/role")
    @Operation(summary = "获取用户角色")
    public AuthInfoRespVO getRoles() {
        List<String> roles = authService.getRoles();
        return AuthInfoRespVO.builder().roles(roles).build();
    }
}
